package com.qf.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsGoodsMapper;
import com.qf.mapper.DtsOrderMapper;
import com.qf.mapper.DtsUserMapper;
import com.qf.pojo.DtsUser;
import com.qf.service.AdminStatService;
import com.qf.vo.DayStatis;
import com.qf.vo.DtsGoodsVo;
import com.qf.vo.DtsOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashSet;
import java.util.List;


@Service
public class AdminStatServiceImpl implements AdminStatService {

    @Autowired
    private DtsUserMapper dtsUserMapper;

    @Autowired
    private DtsOrderMapper dtsOrderMapper;

    @Autowired
    private DtsGoodsMapper dtsGoodsMapper;

    @Override
    public List<DayStatis> selectUser() {

        List<DayStatis> data = dtsUserMapper.selectUser();
        return data;
    }

    @Override
    public HashSet<Date> selectTime() {
        QueryWrapper<DtsUser> wrapper = new QueryWrapper<>();
        wrapper.select("add_time");
        List<DtsUser> time = dtsUserMapper.selectList(wrapper);

        HashSet<Date> dates = new HashSet<>();
        for (int i = 0; i < time.size(); i++) {
            dates.add(time.get(i).getAddTime());
        }

        return dates;
    }

    @Override
    public List<DtsOrderVo> selectOrder() {

        List<DtsOrderVo> dtsOrderVos = dtsOrderMapper.selectOrderList();
        return dtsOrderVos;
    }

    @Override
    public List<DtsGoodsVo> selectGoods() {

        List<DtsGoodsVo> dtsGoodsVos = dtsGoodsMapper.selectGoodsList();

        return dtsGoodsVos;
    }


}
